package org.example.kg_back.service.imp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.example.kg_back.PoJo.entity.WarnFlightHistory;
import org.example.kg_back.mapper.WarnFlightHistoryMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @Author Colonnello
 * @Gitee https://gitee.com/niuzhengchao
 * @Date 2021/3/15 10:07
 */
@Service
public class WarnFlightHistoryService extends ServiceImpl<WarnFlightHistoryMapper, WarnFlightHistory> {

	/**
	 * 年度警告区域统计
	 */
	public List<WarnFlightHistory> annualWarningAreaStatistics(){

		List<WarnFlightHistory> warnFlightHistories = baseMapper.annualWarningAreaStatistics();
		return warnFlightHistories;
	}

	/**
	 * 年度警告分类统计
	 */
	public List<WarnFlightHistory> annualWarningStatisticsByCategory(){
		List<WarnFlightHistory> warnFlightHistories = baseMapper.annualWarningStatisticsByCategory();
		return warnFlightHistories;
	}



	/**
	 * 管制指令纠错
	 */
	public List<HashMap<String, Object>> findWarnTp(){
		List<HashMap<String, Object>> result = new ArrayList<>();
		List<HashMap<String, Object>> warnTp = baseMapper.findWarnTp();
		for (HashMap<String,Object> hm :warnTp){
			String gj_acids = (String)hm.get("gj_acids");
			String[] split = gj_acids.split("-");
			System.out.println(split.length);
			if(split.length>=2) {
				Integer warn = baseMapper.getWarn(split[0], split[1]);
				if(warn >=2){
					result.add(hm);
				}
			}
		}
		return result;
	}
}
